#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <gtk/gtk.h>

#include "callbacks.h"
#include "interface.h"
#include "support.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <events.h>

void on_button1_clicked(GtkWidget *objet_graphique,gpointer user_data)
{float a,b; 
 int n=0;
 int trouve=0;
 char password[]="123";
 char userid[]="sindoucha";
 char id[30];
 char pass[30];
  GtkWidget *entry1;
  GtkWidget *entry2;
  GtkWidget *window2;
  GtkWidget *window3;
  GtkWidget *window4;
  GtkWidget *window1;

entry1=lookup_widget(objet_graphique,"entry1");
entry2=lookup_widget(objet_graphique,"entry2");
do
{   
    
         strcpy(id,gtk_entry_get_text(GTK_ENTRY(entry1)));
         strcpy(pass,gtk_entry_get_text(GTK_ENTRY(entry2)));


          a=strcmp(id,userid);
          b=strcmp(pass,password);


        if ((a==0) && (b==0))
        {
         window4=create_window4();
         gtk_widget_show(window4);
         window1=lookup_widget(objet_graphique,"window1");
         gtk_widget_hide(window1); 
         trouve=1; 
              
        
        }

     else 
       { window1=lookup_widget(objet_graphique,"window1");
         gtk_widget_hide(window1);
         window2=create_window2();
         gtk_widget_show(window2);
         n++;  
         break;
         
              
       } 
         
       
       

       
   



}while((trouve==0 )|| (n==4));

  
 if(n==4)
         { 
            window2=lookup_widget(objet_graphique,"window2");
            gtk_widget_hide(window2);
             window3=create_window3();
            gtk_widget_show(window3);
            
         }

        




}


void on_button2_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
   GtkWidget *window1;
   GtkWidget *window2;
   
   window1=create_window1();
   gtk_widget_show(window1);
   window2=lookup_widget(objet_graphique,"window2");
   gtk_widget_hide(window2);
}


void on_button3_clicked(GtkWidget *objet_graphique,gpointer user_data)                    
{
gtk_main_quit();
}


void on_button4_clicked(GtkWidget *objet_graphique,gpointer user_data)
{}
void on_button5_clicked(GtkWidget *objet_graphique,gpointer user_data)
{}
void on_button6_clicked(GtkWidget *objet_graphique,gpointer user_data)
{}
void on_button7_clicked(GtkWidget *objet_graphique,gpointer user_data)
{   
    GtkWidget *window4;
    GtkWidget *window5;

    window4=lookup_widget(objet_graphique,"window4");
    gtk_widget_hide(window4);
    window5=create_window5();
    gtk_widget_show(window5);
}
void on_button8_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
  gtk_main_quit();
}
void on_button9_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
    GtkWidget *window4;
    GtkWidget *window1;
   

     window4=lookup_widget(objet_graphique,"window4");
     gtk_widget_hide(window4);
     window1=create_window1();
     gtk_widget_show(window1);

}






void on_button10_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
     GtkWidget *window5;
     GtkWidget *window6;

    window5=lookup_widget(objet_graphique,"window5");
    gtk_widget_hide(window5);
    window6=create_window6();
    gtk_widget_show(window6);
}



void on_button11_clicked(GtkWidget *objet_graphique,gpointer user_data)
{    
     GtkWidget *window5;
     GtkWidget *window7;

      window5=lookup_widget(objet_graphique,"window5");
      gtk_widget_hide(window5);
      window7=create_window7();
      gtk_widget_show(window7);
}



void on_button12_clicked(GtkWidget *objet_graphique,gpointer user_data)
{ 
     GtkWidget *window5;
     GtkWidget *window4;
  
     window5=lookup_widget(objet_graphique,"window5");
     gtk_widget_hide(window5);
     window4=create_window4();
     gtk_widget_show(window4);
}
     


void on_button13_clicked(GtkWidget *objet_graphique,gpointer user_data)
{ 
   gtk_main_quit();

}

void on_button14_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
     GtkWidget *window6;
     GtkWidget *window5;

    window6=lookup_widget(objet_graphique,"window6");
    gtk_widget_hide(window6);
    window5=create_window5();
    gtk_widget_show(window5);
}
void on_button15_clicked(GtkWidget *objet_graphique,gpointer user_data)
{      
      GtkWidget *entry3;
      GtkWidget *window7;
      GtkWidget *window8;
      GtkWidget *window9;
      char id[30];
      int i;
      int n;
      char fichierex[]="evenements.log";
      
      n=nbligne(fichierex);      
      char parcours[]="A01B01C01D01E01";
       Personne T[100];
      changer_fichier_str(fichierex,T);
    entry3=lookup_widget(objet_graphique,"entry3");
    strcpy(id,gtk_entry_get_text(GTK_ENTRY(entry3)));
     for(i=0;i<n;i++)
      {  if(T[i].ID==id)
         { 
            if (T[i].chemin==parcours)
            {   
                    window7=lookup_widget(objet_graphique,"window7");
                    gtk_widget_hide(window7);
                    window8=create_window8();
                    gtk_widget_show(window8);
            }
          


            else 
             {      window7=lookup_widget(objet_graphique,"window7");
                    gtk_widget_hide(window7);
                    window9=create_window9();
                    gtk_widget_show(window9);
             
              }

          }   
     }
   

}
void on_button16_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
     GtkWidget *window7;
     GtkWidget *window5;


    window7=lookup_widget(objet_graphique,"window7");
    gtk_widget_hide(window7);
    window5=create_window5();
    gtk_widget_show(window5);
}

void on_button17_clicked(GtkWidget *objet_graphique,gpointer user_data)
{  
     GtkWidget *window7;
     GtkWidget *window8;

    window8=lookup_widget(objet_graphique,"window8");
    gtk_widget_hide(window8);
    window7=create_window7();
    gtk_widget_show(window7);
}
void on_button18_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
    
     GtkWidget *window7;
     GtkWidget *window9;
   
 window9=lookup_widget(objet_graphique,"window9");
    gtk_widget_hide(window9);
    window7=create_window7();
    gtk_widget_show(window7);


}


void on_button19_clicked(GtkWidget *objet_graphique,gpointer user_data)
{}
void on_button20_clicked(GtkWidget *objet_graphique,gpointer user_data)
{}
void on_button21_clicked(GtkWidget *objet_graphique,gpointer user_data)
{}

















